# -*- coding: utf-8 -*-
# Date: 2025/7/23 14:51
import json

from config.default_settings import mysql_database_bzx
from utils.mysql_util import MysqlHelper

template = "INSERT INTO `bzx_service_2000`.`bas_dic_cols` (`guid`, `dic_id`, `field`, `title`, `title_tip`, `parent_id`, `remark`, `order_num`, `col_type`, `clengh`, `editable`, `disabled`, `align`, `sortable`, `visible`, `required`, `options`, `width`, `placeholder`, `default_value`, `formula`, `calcpri`, `creater`, `updater`, `create_time`, `update_time`, `is_deleted`, `mof_div_code`, `fiscal_year`, `column_name`, `formula_show`, `is_export_col`, `graded_summary`, `fixed`, `is_search_col`, `constraint_exp`, `is_standard`) VALUES ('{guidValue}', '{dicCodeValue}', 'verifyStatus', '勾稽审核状态', NULL, NULL, NULL, '0002.1', '$vxeSelect', 2, 1, 1, 'left', 0, 1, 0, '1=未校验#2=校验通过#3=校验未通过', 180, '', '', NULL, NULL, 'system', 'system', '2025-07-23 15:10:57', '2025-07-23 15:10:57', 2, '630000000', '2025', 'verify_status', NULL, 1, NULL, NULL, 0, NULL, NULL);"

if __name__ == '__main__':
    mysql_helper = MysqlHelper(mysql_database_bzx)
    menu_list = mysql_helper.get_list(
        "SELECT * FROM `bzx_service_2000`.`menu` WHERE `param1` LIKE '%\"is_source\":\"2\"%' LIMIT 0,1000")

    bas_dic_info_id_list = []
    for menu in menu_list:
        param1_json = menu.get("param1")
        name = menu.get("name")
        param1 = json.loads(param1_json)
        list_dic_code = param1.get("list_dic_code")
        bas_dic_info_list = mysql_helper.get_list(
            "SELECT * FROM `bzx_service_2000`.`bas_dic_info` WHERE `dic_code` = '" + list_dic_code + "'")
        print("------------------------------")
        bas_dic_info_id_list.append(bas_dic_info_list[0].get("table_name"))
        print(bas_dic_info_list[0].get("table_name").lower())
        print(bas_dic_info_list[0].get("report_vname").lower())
        print(name)

    # print("------------------------------")
    # print(','.join(bas_dic_info_id_list))
    # for item in bas_dic_info_id_list:
    #     bas_dic_cols_data = mysql_helper.get_list(f"SELECT * FROM `bzx_service_2000`.`bas_dic_cols` WHERE `dic_id` = '{item}' ORDER BY `order_num` LIMIT 0,1000")
    #     index = 1
    #     for col in bas_dic_cols_data:
    #         guid = col.get("guid")
    #         order_num = str(index).rjust(4,'0')
    #         sql = f"update  bas_dic_cols set order_num = '{order_num}' where guid = '{guid}';"
    #         mysql_helper.execute_sql(sql)
    #         index = index + 1
    #
    #
    #     print("------------------------------")
